
import math


def eff1(p):    
    assert math.fabs(sum(p)-1)<1e-7
    n=0.
    for v in p:
        n+=v**2
    return 1./n
    
    
def eff2(p):
    assert math.fabs(sum(p)-1)<1e-7    
    h=0.
    for v in p:
        if v>0:
            h+=-v*math.log(v)
    return math.exp(h)


p=[1.,2.,1.]
sump=sum(p)
p=[v/sump for v in p]
print eff1(p), eff2(p)
